﻿
namespace Common.Utility
{
    /// <summary>
    /// 进程处理辅助工具类
    /// </summary>
    public class ProcessHelper
    {
        /// <summary>
        /// 读取当前进程占用内存(MB)
        /// </summary>
        /// <returns></returns>
        public static double MemeryRead()
        {
            double mem = 0;
            using (System.Diagnostics.PerformanceCounter pc = new System.Diagnostics.PerformanceCounter("Process", "Private Bytes", System.Diagnostics.Process.GetCurrentProcess().ProcessName))
            {
                mem = (pc.NextValue() / (1024 * 1024));
            }
            return mem;
        }
    }
}
